package com.fumin.controller;
import com.fumin.beans.PageQuery;
import com.fumin.common.JsonData;
import com.fumin.param.SearchLogParam;
import com.fumin.service.SysLogService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * 日志controller
 * @Author xiayuxuanmin
 * @Date 2019/11/22
 * @Description
 */
@Controller
@RequestMapping("/sys/log")
public class SysLogController {

    @Resource
    private SysLogService sysLogService;

    /**
     * 日志页面
     * @return
     */
    @RequestMapping("/log.page")
    public ModelAndView page(){
        return new ModelAndView("log");
    }

    /**
     * 查询分页数据
     * @param param
     * @param query
     * @return
     */
    @RequestMapping("/page.json")
    @ResponseBody
    public JsonData searchPage(SearchLogParam param, PageQuery query){
        return JsonData.success(sysLogService.searchPageList(param,query));
    }

    /**
     * 数据还原
     * @param id
     * @return
     */
    @RequestMapping("/recover.json")
    @ResponseBody
    public JsonData searchPage(int id){
        sysLogService.recover(id);
        return JsonData.success();
    }
}
